package main

import "fmt"

//据表变量 形参 栈基和栈顶描述符
//函数传参 值传递

func swap(a, b int) (int, int) {
	a, b = b, a
	fmt.Printf("\nswap a = %v, b = %v\n", a, b)
	return a, b
}

func swap_p(a, b *int) (int, int) {
	*a, *b = *b, *a
	fmt.Printf("\nswap_p a = %v, b = %v\n", a, b)
	return *a, *b
}

func main() {
	a, b := 10, 20
	c, d := swap(a, b)
	fmt.Printf("main a = %v, b = %v\n", a, b)
	fmt.Printf("main c = %v, d = %v\n", c, d)
	fmt.Println("---------------------\n")
	e, f := swap_p(&a, &b)
	fmt.Printf("main a = %v, b = %v\n", a, b)
	fmt.Printf("main e = %v, f = %v\n", e, f)
}
